home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / QuickDraw3D 1.6 SDK / Mac SampleCode New for 1.6 / CompressedPixmapSample / Source / QD3D_Support.c < prev   
Encoding:
C/C++ Source or Header  |  1999-05-18  |  17.3 KB  |  605 lines  |  [TEXT/CWIE]

  1. /****************************/
  2. /*       QD3D SUPPORT.C        */
  3. /* By Brian Greenstone      */
  4. /****************************/
  5.  
  6.  
  7. /****************************/
  8. /*    EXTERNALS             */
  9. /****************************/
  10. #include <NumberFormatting.h>
  11. #include <Timer.h>
  12.  
  13. #include <QD3D.h>
  14. #include <QD3DGroup.h>
  15. #include <QD3DLight.h>
  16. #include <QD3DTransform.h>
  17. #include <QD3DStorage.h>
  18. #include <QD3DMath.h>
  19. #include <QD3DErrors.h>
  20. #include <ImageCompression.h>
  21.  
  22. #include "myglobals.h"
  23. #include "misc.h"
  24. #include "qd3d_support.h"
  25.  
  26. extern    EventRecord            gTheEvent;
  27. extern    WindowPtr            gModelWindow;
  28. extern    Str255            gCompressionRatio,gCompressionSize;
  29.  
  30. /****************************/
  31. /*    PROTOTYPES            */
  32. /****************************/
  33.  
  34. static void CreateDrawContext(QD3DViewDefType *viewDefPtr);
  35. static void SetStyles(QD3DStyleDefType *styleDefPtr);
  36. static void CreateCamera(QD3DCameraDefType *cameraDefPtr);
  37. static void CreateLights(QD3DLightDefType *lightDefPtr);
  38. static void CreateView(QD3DSetupInputType *setupDefPtr);
  39. static void CreateTexturePixmap(PicHandle pict,unsigned long mapSizeX,
  40.                              unsigned long mapSizeY, TQ3CompressedPixmap *bMap);
  41. static void TraverseDisplayGroupInfo(TQ3Object theGroup);
  42. static void ShowMeshInfo(TQ3Object theMesh);
  43. static void ShowAttributeInfo(TQ3AttributeSet theAttribute);
  44. static void ShowTriMeshInfo(TQ3Object theTriMesh);
  45.  
  46.  
  47. /****************************/
  48. /*    CONSTANTS             */
  49. /****************************/
  50.  
  51.  
  52. /*********************/
  53. /*    VARIABLES      */
  54. /*********************/
  55.  
  56. static TQ3CameraObject            gQD3D_CameraObject;
  57. static TQ3GroupObject            gQD3D_LightGroup;
  58. static TQ3ViewObject            gQD3D_ViewObject;
  59. static TQ3DrawContextObject        gQD3D_DrawContext;
  60. static TQ3RendererObject        gQD3D_RendererObject;
  61. static TQ3ShaderObject            gQD3D_ShaderObject;
  62. static    TQ3StyleObject            gQD3D_BackfacingStyle;
  63. static    TQ3StyleObject            gQD3D_FillStyle;
  64. static    TQ3StyleObject            gQD3D_InterpolationStyle;
  65.  
  66. float    gFramesPerSecond = DEFAULT_FPS;                // this is used to maintain a constant timing velocity as frame rates differ
  67.  
  68.  
  69.  
  70.  
  71. //=======================================================================================================
  72. //=============================== VIEW WINDOW SETUP STUFF ===============================================
  73. //=======================================================================================================
  74.  
  75.  
  76. /************** SETUP QD3D WINDOW *******************/
  77.  
  78. void QD3D_SetupWindow(QD3DSetupInputType *setupDefPtr, QD3DSetupOutputType *outputPtr)
  79. {
  80.     CreateView(setupDefPtr);
  81.     Q3InteractiveRenderer_SetDoubleBufferBypass(gQD3D_RendererObject,kQ3True);        // let hardware go fast    
  82.     CreateCamera(&setupDefPtr->camera);                                        // create new CAMERA object
  83.     CreateLights(&setupDefPtr->lights);
  84.     SetStyles(&setupDefPtr->styles);    
  85.     
  86.  
  87.                 /* DISPOSE OF EXTRA REFERENCES */
  88.                 
  89.     Q3Object_Dispose(gQD3D_RendererObject);                // (is contained w/in gQD3D_ViewObject)
  90.  
  91.     
  92.                 /* PASS BACK INFO */
  93.                 
  94.     outputPtr->viewObject = gQD3D_ViewObject;
  95.     outputPtr->interpolationStyle = gQD3D_InterpolationStyle;
  96.     outputPtr->fillStyle = gQD3D_FillStyle;
  97.     outputPtr->backfacingStyle = gQD3D_BackfacingStyle;
  98.     outputPtr->shaderObject = gQD3D_ShaderObject;
  99.     outputPtr->cameraObject = gQD3D_CameraObject;
  100.     outputPtr->lightGroup = gQD3D_LightGroup;
  101.     outputPtr->drawContext = gQD3D_DrawContext;
  102.     outputPtr->window = setupDefPtr->view.displayWindow;        // remember which window
  103.     outputPtr->paneClip = setupDefPtr->view.paneClip;
  104. }
  105.  
  106.  
  107. /***************** QD3D_DisposeWindowSetup ***********************/
  108. //
  109. // Disposes of all data created by QD3D_SetupWindow
  110. //
  111.  
  112. void QD3D_DisposeWindowSetup(QD3DSetupOutputType *data)
  113. {
  114.     Q3Object_Dispose(data->viewObject);
  115.     Q3Object_Dispose(data->interpolationStyle);
  116.     Q3Object_Dispose(data->backfacingStyle);
  117.     Q3Object_Dispose(data->fillStyle);
  118.     Q3Object_Dispose(data->cameraObject);
  119.     Q3Object_Dispose(data->lightGroup);
  120.     Q3Object_Dispose(data->drawContext);
  121.     Q3Object_Dispose(data->shaderObject);
  122. }
  123.  
  124.  
  125. /******************* CREATE GAME VIEW *************************/
  126.  
  127. static void CreateView(QD3DSetupInputType *setupDefPtr)
  128. {
  129. TQ3Status    myErr;
  130. unsigned long    hints;
  131.  
  132.                 /* CREATE NEW VIEW OBJECT */
  133.                 
  134.     gQD3D_ViewObject = Q3View_New();
  135.     if (gQD3D_ViewObject == nil)
  136.         DoFatalAlert("\pQ3View_New failed!");
  137.  
  138.  
  139.             /* CREATE & SET DRAW CONTEXT */
  140.     
  141.     CreateDrawContext(&setupDefPtr->view);                                 // init draw context
  142.     
  143.     myErr = Q3View_SetDrawContext(gQD3D_ViewObject, gQD3D_DrawContext);            // assign context to view
  144.     if (myErr == kQ3Failure)
  145.         DoFatalAlert("\pQ3View_SetDrawContext Failed!");
  146.  
  147.  
  148.  
  149.             /* CREATE & SET RENDERER */
  150.  
  151.     gQD3D_RendererObject = Q3Renderer_NewFromType(setupDefPtr->view.rendererType);    // create new RENDERER object
  152.     if (gQD3D_RendererObject == nil)
  153.     {
  154.         QD3D_ShowError("\pQ3Renderer_NewFromType Failed!", true);
  155.         CleanQuit();
  156.     }
  157.  
  158.     myErr = Q3View_SetRenderer(gQD3D_ViewObject, gQD3D_RendererObject);                // assign renderer to view
  159.     if (myErr == kQ3Failure)
  160.         DoFatalAlert("\pQ3View_SetRenderer Failed!");
  161.  
  162.         /* SET RENDERER FEATURES */
  163.         
  164.     Q3InteractiveRenderer_GetRAVEContextHints(gQD3D_RendererObject, &hints);
  165.     hints &= ~kQAContext_NoZBuffer;                 // Z buffer is on 
  166.     hints &= ~kQAContext_DeepZ;                     // Z buffer is not deep, ergo it's shallow 
  167.     hints |= kQAContext_NoDither;                     // No Dither 
  168.     Q3InteractiveRenderer_SetRAVEContextHints(gQD3D_RendererObject, hints);    
  169.     
  170.     Q3InteractiveRenderer_SetRAVETextureFilter(gQD3D_RendererObject,kQATextureFilter_Best);    
  171.     Q3InteractiveRenderer_SetDoubleBufferBypass(gQD3D_RendererObject,kQ3True);
  172. }
  173.  
  174.  
  175. /**************** CREATE SKELETON DRAW CONTEXT *********************/
  176.  
  177. static void CreateDrawContext(QD3DViewDefType *viewDefPtr)
  178. {
  179. TQ3DrawContextData        drawContexData;
  180. TQ3MacDrawContextData    myMacDrawContextData;
  181. Rect                    r;
  182.  
  183.     r = viewDefPtr->displayWindow->portRect;
  184.  
  185.  
  186.             /* FILL IN DRAW CONTEXT DATA */
  187.  
  188.     drawContexData.clearImageMethod = kQ3ClearMethodWithColor;                // how to clear
  189.     drawContexData.clearImageColor = viewDefPtr->clearColor;                // color to clear to
  190.     drawContexData.pane.min.x = r.left+viewDefPtr->paneClip.left;            // set bounds?
  191.     drawContexData.pane.max.x = r.right-viewDefPtr->paneClip.right;
  192.     drawContexData.pane.min.y = r.top+viewDefPtr->paneClip.top;
  193.     drawContexData.pane.max.y = r.bottom-viewDefPtr->paneClip.bottom;
  194.     drawContexData.paneState = kQ3True;                                        // use bounds?
  195.     drawContexData.maskState = kQ3False;                                    // no mask
  196.     drawContexData.doubleBufferState = kQ3True;                                // double buffering
  197.  
  198.     myMacDrawContextData.drawContextData = drawContexData;                    // set MAC specifics
  199.     myMacDrawContextData.window = (CWindowPtr)viewDefPtr->displayWindow;    // assign window to draw to
  200.     myMacDrawContextData.library = kQ3Mac2DLibraryNone;                        // use standard QD libraries (no GX crap!)
  201.     myMacDrawContextData.viewPort = nil;                                    // (for GX only)
  202.     myMacDrawContextData.grafPort = (CWindowPtr)viewDefPtr->displayWindow;    // assign grafport
  203.  
  204.  
  205.             /* CREATE DRAW CONTEXT */
  206.  
  207.     gQD3D_DrawContext = Q3MacDrawContext_New(&myMacDrawContextData);
  208.     if (gQD3D_DrawContext == nil)
  209.         DoFatalAlert("\pQ3MacDrawContext_New Failed!");
  210. }
  211.  
  212.  
  213. /**************** SET STYLES ****************/
  214. //
  215. // Creates style objects which define how the scene is to be rendered.
  216. // It also sets the shader object.
  217. //
  218.  
  219. static void SetStyles(QD3DStyleDefType *styleDefPtr)
  220. {
  221.  
  222.                 /* SET INTERPOLATION (FOR SHADING) */
  223.                     
  224.     gQD3D_InterpolationStyle = Q3InterpolationStyle_New(styleDefPtr->interpolation);
  225.     if (gQD3D_InterpolationStyle == nil)
  226.         DoFatalAlert("\pQ3InterpolationStyle_New Failed!");
  227.  
  228.                     /* SET BACKFACING */
  229.  
  230.     gQD3D_BackfacingStyle = Q3BackfacingStyle_New(styleDefPtr->backfacing);
  231.     if (gQD3D_BackfacingStyle == nil )
  232.         DoFatalAlert("\pQ3BackfacingStyle_New Failed!");
  233.  
  234.  
  235.                 /* SET POLYGON FILL STYLE */
  236.                         
  237.     gQD3D_FillStyle = Q3FillStyle_New(styleDefPtr->fill);
  238.     if ( gQD3D_FillStyle == nil )
  239.         DoFatalAlert("\p Q3FillStyle_New Failed!");
  240.  
  241.  
  242.                     /* SET THE SHADER TO USE */
  243.  
  244.     switch(styleDefPtr->illuminationType)
  245.     {
  246.         case    kQ3IlluminationTypePhong:
  247.                 gQD3D_ShaderObject = Q3PhongIllumination_New();
  248.                 if ( gQD3D_ShaderObject == nil )
  249.                     DoFatalAlert("\p Q3PhongIllumination_New Failed!");
  250.                 break;
  251.                 
  252.         case    kQ3IlluminationTypeLambert:
  253.                 gQD3D_ShaderObject = Q3LambertIllumination_New();
  254.                 if ( gQD3D_ShaderObject == nil )
  255.                     DoFatalAlert("\p Q3LambertIllumination_New Failed!");
  256.                 break;
  257.                 
  258.         case    kQ3IlluminationTypeNULL:
  259.                 gQD3D_ShaderObject = Q3NULLIllumination_New();
  260.                 if ( gQD3D_ShaderObject == nil )
  261.                     DoFatalAlert("\p Q3NullIllumination_New Failed!");
  262.                 break;
  263.     }    
  264. }
  265.  
  266.  
  267.  
  268. /****************** CREATE CAMERA *********************/
  269.  
  270. static void CreateCamera(QD3DCameraDefType *cameraDefPtr)
  271. {
  272. TQ3CameraData                    myCameraData;
  273. TQ3ViewAngleAspectCameraData    myViewAngleCameraData;
  274. TQ3Area                            pane;
  275. TQ3Status                        status;
  276. TQ3Status    myErr;
  277.  
  278.     status = Q3DrawContext_GetPane(gQD3D_DrawContext,&pane);                // get window pane info
  279.     if (status == kQ3Failure)
  280.         DoFatalAlert("\pQ3DrawContext_GetPane Failed!");
  281.  
  282.  
  283.                 /* FILL IN CAMERA DATA */
  284.                 
  285.     myCameraData.placement.cameraLocation = cameraDefPtr->from;            // set camera coords
  286.     myCameraData.placement.pointOfInterest = cameraDefPtr->to;            // set target coords
  287.     myCameraData.placement.upVector = cameraDefPtr->up;                    // set a vector that's "up"
  288.     myCameraData.range.hither = cameraDefPtr->hither;                    // set frontmost Z dist
  289.     myCameraData.range.yon = cameraDefPtr->yon;                            // set farthest Z dist
  290.     myCameraData.viewPort.origin.x = -1.0;                                // set view origins?
  291.     myCameraData.viewPort.origin.y = 1.0;
  292.     myCameraData.viewPort.width = 2.0;
  293.     myCameraData.viewPort.height = 2.0;
  294.  
  295.     myViewAngleCameraData.cameraData = myCameraData;
  296.     myViewAngleCameraData.fov = cameraDefPtr->fov;                        // larger = more fisheyed
  297.     myViewAngleCameraData.aspectRatioXToY =
  298.                 (pane.max.x-pane.min.x)/(pane.max.y-pane.min.y);
  299.  
  300.     gQD3D_CameraObject = Q3ViewAngleAspectCamera_New(&myViewAngleCameraData);     // create new camera
  301.     if (gQD3D_CameraObject == nil)
  302.         DoFatalAlert("\pQ3ViewAngleAspectCamera_New failed!");
  303.         
  304.     myErr = Q3View_SetCamera(gQD3D_ViewObject, gQD3D_CameraObject);        // assign camera to view
  305.     if (myErr == kQ3Failure)
  306.         DoFatalAlert("\pQ3View_SetCamera Failed!");
  307.  
  308. }
  309.  
  310.  
  311. /********************* CREATE LIGHTS ************************/
  312.  
  313. static void CreateLights(QD3DLightDefType *lightDefPtr)
  314. {
  315. TQ3GroupPosition        myGroupPosition;
  316. TQ3LightData            myLightData;
  317. TQ3DirectionalLightData    myDirectionalLightData;
  318. TQ3LightObject            myLight;
  319. short                    i;
  320. TQ3Status    myErr;
  321.  
  322.  
  323.             /* CREATE NEW LIGHT GROUP */
  324.             
  325.     gQD3D_LightGroup = Q3LightGroup_New();                        // make new light group
  326.     if ( gQD3D_LightGroup == nil )
  327.         DoFatalAlert("\p Q3LightGroup_New Failed!");
  328.  
  329.  
  330.     myLightData.isOn = kQ3True;                                    // light is ON
  331.     
  332.             /************************/
  333.             /* CREATE AMBIENT LIGHT */
  334.             /************************/
  335.  
  336.     if (lightDefPtr->ambientBrightness != 0)                        // see if ambient exists
  337.     {
  338.         myLightData.color = lightDefPtr->ambientColor;                // set color of light
  339.         myLightData.brightness = lightDefPtr->ambientBrightness;    // set brightness value
  340.         myLight = Q3AmbientLight_New(&myLightData);                    // make it
  341.         if ( myLight == nil )
  342.             DoFatalAlert("\pQ3AmbientLight_New Failed!");
  343.  
  344.         myGroupPosition = Q3Group_AddObject(gQD3D_LightGroup, myLight);    // add to group
  345.         if ( myGroupPosition == 0 )
  346.             DoFatalAlert("\p Q3Group_AddObject Failed!");
  347.  
  348.         Q3Object_Dispose(myLight);                                    // dispose of light
  349.  
  350.     }
  351.  
  352.             /**********************/
  353.             /* CREATE FILL LIGHTS */
  354.             /**********************/
  355.             
  356.     for (i=0; i < lightDefPtr->numFillLights; i++)
  357.     {        
  358.         myLightData.color = lightDefPtr->fillColor[i];                        // set color of light
  359.         myLightData.brightness = lightDefPtr->fillBrightness[i];            // set brightness
  360.         myDirectionalLightData.lightData = myLightData;                        // refer to general light info
  361.         myDirectionalLightData.castsShadows = kQ3False;                        // no shadows
  362.         myDirectionalLightData.direction =  lightDefPtr->fillDirection[i];    // set fill vector
  363.         myLight = Q3DirectionalLight_New(&myDirectionalLightData);            // make it
  364.         if ( myLight == nil )
  365.             DoFatalAlert("\p Q3DirectionalLight_New Failed!");
  366.  
  367.         myGroupPosition = Q3Group_AddObject(gQD3D_LightGroup, myLight);        // add to group
  368.         if ( myGroupPosition == 0 )
  369.             DoFatalAlert("\p Q3Group_AddObject Failed!");
  370.  
  371.         Q3Object_Dispose(myLight);                                            // dispose of light
  372.     }
  373.     
  374.             /* ASSIGN LIGHT GROUP TO VIEW */
  375.             
  376.     myErr = Q3View_SetLightGroup(gQD3D_ViewObject, gQD3D_LightGroup);        // assign light group to view
  377.     if (myErr == kQ3Failure)
  378.         DoFatalAlert("\pQ3View_SetLightGroup Failed!");        
  379.  
  380. }
  381.  
  382. /******************** QD3D CHANGE DRAW SIZE *********************/
  383. //
  384. // Changes size of stuff to fit new window size.
  385. //
  386.  
  387. void QD3D_ChangeDrawSize(QD3DSetupOutputType *setupInfo)
  388. {
  389. Rect            r;
  390. TQ3Area            pane;
  391. TQ3ViewAngleAspectCameraData    cameraData;
  392.  
  393.             /* CHANGE DRAW CONTEXT PANE SIZE */
  394.             
  395.     r = setupInfo->window->portRect;                            // get size of window
  396.     pane.min.x = r.left+setupInfo->paneClip.left;                                        // set pane size
  397.     pane.max.x = r.right-setupInfo->paneClip.right;
  398.     pane.min.y = r.top+setupInfo->paneClip.top;
  399.     pane.max.y = r.bottom-setupInfo->paneClip.bottom;
  400.     Q3DrawContext_SetPane(setupInfo->drawContext,&pane);        // update pane in draw context
  401.  
  402.  
  403.                 /* CHANGE CAMERA ASPECT RATIO */
  404.                 
  405.     Q3ViewAngleAspectCamera_GetData(setupInfo->cameraObject,&cameraData);            // get camera data
  406.     cameraData.aspectRatioXToY = (pane.max.x-pane.min.x)/(pane.max.y-pane.min.y);    // set new aspect ratio
  407.     Q3ViewAngleAspectCamera_SetData(setupInfo->cameraObject,&cameraData);            // set new camera data
  408. }
  409.  
  410.  
  411. /******************* QD3D DRAW SCENE *********************/
  412.  
  413. void QD3D_DrawScene(QD3DSetupOutputType *setupInfo, void (*drawRoutine)(QD3DSetupOutputType *))
  414. {
  415. TQ3Status                myStatus;
  416. TQ3ViewStatus            myViewStatus;
  417.  
  418.             /* START RENDERING */
  419.  
  420. //startTrace("test.tt6");
  421.  
  422.     myStatus = Q3View_StartRendering(setupInfo->viewObject);            
  423.     if ( myStatus == kQ3Failure )
  424.     {
  425.         DoFatalAlert("\p Q3View_StartRendering Failed!");
  426.     }
  427.     
  428.             /***************/
  429.             /* RENDER LOOP */
  430.             /***************/
  431.     do
  432.     {
  433.                 /* DRAW STYLES */
  434.                 
  435.         myStatus = Q3Style_Submit(setupInfo->interpolationStyle,setupInfo->viewObject);
  436.         if ( myStatus == kQ3Failure )
  437.             DoFatalAlert("\p Q3Style_Submit Failed!");
  438.             
  439.         myStatus = Q3Style_Submit(setupInfo->backfacingStyle,setupInfo->viewObject);
  440.         if ( myStatus == kQ3Failure )
  441.             DoFatalAlert("\p Q3Style_Submit Failed!");
  442.             
  443.         myStatus = Q3Style_Submit(setupInfo->fillStyle, setupInfo->viewObject);
  444.         if ( myStatus == kQ3Failure )
  445.             DoFatalAlert("\p Q3Style_Submit Failed!");
  446.  
  447.         myStatus = Q3Shader_Submit(setupInfo->shaderObject, setupInfo->viewObject);
  448.         if ( myStatus == kQ3Failure )
  449.             DoFatalAlert("\p Q3Shader_Submit Failed!");
  450.  
  451.  
  452.             /* CALL INPUT DRAW FUNCTION */
  453.  
  454.         drawRoutine(setupInfo);
  455.  
  456.         myViewStatus = Q3View_EndRendering(setupInfo->viewObject);
  457.         
  458.     } while ( myViewStatus == kQ3ViewStatusRetraverse );
  459.     
  460. //stopTrace();
  461. //CleanQuit();
  462. }
  463.  
  464.  
  465. //=======================================================================================================
  466. //=============================== MISC ==================================================================
  467. //=======================================================================================================
  468.  
  469. /************** QD3D CALC FRAMES PER SECOND *****************/
  470.  
  471. float    QD3D_CalcFramesPerSecond(void)
  472. {
  473. UnsignedWide    wide;
  474. unsigned long    now;
  475. static    unsigned long then = 0;
  476.  
  477.     Microseconds(&wide);
  478.     now = wide.lo;
  479.     if (then != 0)
  480.     {
  481.         gFramesPerSecond = (float)1000000.0/(float)(now-then);
  482.         if (gFramesPerSecond < DEFAULT_FPS)            // (avoid divide by 0's later)
  483.             gFramesPerSecond = DEFAULT_FPS;
  484.     
  485. //        if (gTheEvent.modifiers & shiftKey)
  486.         {
  487.             SetPort(gModelWindow);
  488.             ForeColor(yellowColor);
  489.             BackColor(blackColor);
  490.             TextMode(srcCopy);
  491.             TextSize(12);
  492.             TextFace(bold);
  493.             MoveTo(10,13);
  494.             DrawString("\pCompression % = ");
  495.             DrawString(gCompressionRatio);
  496.             DrawString("\p    #Bytes = ");
  497.             DrawString(gCompressionSize);
  498.             DrawString("\p             ");
  499.         }
  500.     }
  501.     else
  502.         gFramesPerSecond = DEFAULT_FPS;
  503.         
  504.     then = now;                                // remember time    
  505.     
  506.     return(gFramesPerSecond);
  507. }
  508.  
  509.  
  510. #pragma mark ========== error stuff ===========
  511.  
  512.  
  513. /******************* QD3D: SHOW ERROR *************************/
  514. //
  515. // Returns true if Error, false if just a warning.
  516. //
  517.  
  518. Boolean QD3D_ShowError(Str255 errString, Boolean showWarnings)
  519. {
  520. TQ3Error    err;
  521. TQ3Warning    warning;
  522. Str255        numStr;
  523.  
  524.         /* DO ERRORS */
  525.         
  526.     err = Q3Error_Get(nil);
  527.     if (err != 0)
  528.     {
  529.         DoAlert(errString);
  530.         switch(err)
  531.         {
  532.             case    kQ3ErrorViewNotStarted:
  533.                     DoFatalAlert("\pError:kQ3ErrorViewNotStarted");
  534.                     break;
  535.                     
  536.             case    kQ3ErrorOutOfMemory:
  537.                     DoFatalAlert("\pError:kQ3ErrorOutOfMemory");
  538.                     break;
  539.                     
  540.             default:
  541.                     ShowSystemErr(err);
  542.         }
  543.         return(true);
  544.     }
  545.     
  546.         /* DO WARNINGS */
  547.     else
  548.     {
  549.         if (!showWarnings)
  550.             return(false);
  551.         
  552.         DoAlert(errString);
  553.         warning = Q3Warning_Get(nil);
  554.         switch(warning)
  555.         {
  556.             case    kQ3WarningFunctionalityNotSupported:
  557.                     DoAlert("\pWarning: kQ3WarningFunctionalityNotSupported");
  558.                     break;
  559.                     
  560.             default:
  561.                     NumToString(err, numStr);
  562.                     DoAlert (numStr);
  563.         }
  564.         return(false);
  565.     }
  566.     
  567.     
  568. }
  569.  
  570.  
  571. /************ QD3D: SHOW RECENT ERROR *******************/
  572.  
  573. void QD3D_ShowRecentError(void)
  574. {
  575. TQ3Error    q3Err;
  576. Str255        s;
  577.     
  578.     q3Err = Q3Error_Get(nil);
  579.     if (q3Err == kQ3ErrorOutOfMemory)
  580.         QD3D_DoMemoryError();
  581.     else
  582.     if (q3Err == kQ3ErrorMacintoshError)
  583.         DoFatalAlert("\pkQ3ErrorMacintoshError");
  584.     else
  585.     if (q3Err != 0)
  586.     {
  587.         NumToString(q3Err,s);
  588.         DoFatalAlert(s);
  589.     }
  590. }
  591.  
  592. /***************** QD3D: DO MEMORY ERROR **********************/
  593.  
  594. void QD3D_DoMemoryError(void)
  595. {
  596.     InitCursor();
  597.     NoteAlert(129,nil);
  598.     CleanQuit();
  599. }
  600.  
  601.  
  602.  
  603.  
  604.  
  605.